package com.prpat;

import java.net.ServerSocket;
import java.net.Socket;


class Server implements Runnable
{
	@Override
	public void run() 
	{
		try
		{
			ServerSocket serverSock = new ServerSocket( TaskAssistant.CHAT_PORT );
			while(TaskAssistant.CONNECTED) 
			{
				Socket clientSocket = serverSock.accept();
				
				Thread t = new Thread(new MessageHandler(clientSocket));
				t.setName("MessageHandler");
				t.start();
			}
		}
		catch (Exception ex) 
		{ 
			System.err.println("Error in chat server");
		}
	}

}
